<template>
  <div>
    <div
      style="line-height: 18px;font-weight: 500; font-size: 13px; padding: 10px 16px 12px;font-weight: bolder"
    >
      分组项
    </div>
    <div style="margin-left: 10px">
      <div v-for="(v,index) in groupBy" class="row___xwl">
        <div class="action-row">
          <div>
            <el-tag>{{ index+1 }}</el-tag>
            <el-tag effect="dark">{{ typeTag }}</el-tag>
            <el-select v-model="groupBy[index]" size="mini" placeholder="请选择" filterable>

              <el-option-group
                v-for="group in options"
                :key="group.label"
                :label="group.label"
              >
                <el-option
                  v-for="item in group.options"
                  :key="item.value"
                  :disabled="filterMapGroupDisable(item.value)"
                  :label="item.label"
                  :value="item.value"
                />
              </el-option-group>
            </el-select>
          </div>
          <div>
            <a-button
              type="link"
              class="actions_xwl_btn"
              icon="close-circle"
              @click.native=" delFliterGroupBy(index)"
            />
          </div>
        </div>
      </div>
    </div>
    <div v-if="this.groupBy.length<this.limit" style="margin-top: 4px; padding: 0 12px;">
      <span class="footadd___2D4YB" @click="addFliterGroupBy">
        <a-icon type="apartment" />
        增加分组项
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Index',
  props: {
    value: {
      type: Array,
      default: []
    },
    options: {
      type: Array,
      default: []
    },
    limit: {
      type: Number,
      default: 1
    },
    typeTag: {
      type: String,
      default: '事件'
    }
  },
  data() {
    return {
      groupBy: this.value
    }
  },
  watch: {
    value: {
      deep: true,
      handler() {
        this.groupBy = this.value
      }
    }
  },
  methods: {

    filterMapGroupDisable(v) {
      for (const tmp of this.groupBy) {
        if (tmp.columnName == v) {
          return true
        }
      }
      return false
    },
    addFliterGroupBy() {
      if (this.groupBy.length >= this.limit) return

      this.groupBy.push('')
      this.$emit('input', this.groupBy)
    },
    delFliterGroupBy(index) {
      this.groupBy.splice(index, 1)
      this.$emit('input', this.groupBy)
    }
  }
}
</script>

<style lang="scss" scoped>
  .right_icon:hover{
    color: red;
  }
  .sider_xwl {
    display: inline-block;
    width: 270px;
    height: calc(100vh - 50px);
    padding: 0;
    overflow: hidden;
    vertical-align: top;
  }

  .top_xwl {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 57px;
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    padding-right: 20px;
  }

  .body_xwl {
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    height: calc(100vh - 120px);
    overflow-y: auto;
    background-color: white;
  }

  .content_xwl {
    display: inline-block;
    width: 100%;
    height: calc(100vh - 50px);
    padding: 0;
    overflow: hidden;
    vertical-align: top;
    background: #f0f2f5;
    border-bottom: 2px solid #e6e6e6;
  }

  .header_xwl {
    position: relative;
    z-index: 1000;
    width: 100%;
    height: 56px;
    padding: 0;
    line-height: 56px;

  }

  .main_xwl {
    display: flex;
    align-items: center;
  }

  .title_xwl {
    display: inline-block;
    margin-right: 16px;
    color: black;
    font-weight: 500;
    font-size: 18px;
  }

  .dashbordName_xwl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;

    border-radius: 2px;
    cursor: pointer;
  }

  .root_xwl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 56px;
    padding: 0 16px;
    background-color: #fff;
    border-left: 1px solid #f0f0f0;
  }

  .actions_xwl {
    display: flex;
    align-items: center;
  }

  .actions_xwl_btn:hover {
    color: orangered;
  }

  .actions_xwl_btn {
    color: #67729d;
  }

  .echartBox {
    width: 48%;
    height: 400px;
    padding: 5px;
    margin-bottom: 5px;
  }

  .echartBox:hover {
    cursor: pointer;
  }

  .echartBox_title {
    cursor: pointer;
  }

  .echartBox_title:hover {
    color: #3d90ff;
  }

  .footadd___2D4YB {
    display: inline-block;
    margin-right: 16px;
    padding: 4px;
    color: #3d90ff;
    font-size: 13px;
    line-height: 20px;
    border-radius: 2px;
    cursor: pointer;
    transition: all .3s;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .right_res {
    position: relative;
    width: 100%;
    height: calc(100% - 32px);

    overflow-x: hidden;
    overflow-y: auto;
    white-space: normal;
    transition: width .3s;
  }

  .row___xwl {
    min-height: 40px;
    padding: 0 4px 0 8px;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
    padding: 10px;
  }

  .row___xwl:hover {
    box-shadow: 0 0 3px 0 #1890ff;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .action-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 24px;
  }

  .relation-relation-line {
    position: absolute;
    top: 0;
    left: 12px;
    width: 1px;
    height: 100%;
    background-color: #d9dfe6;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .relation-relation-value {
    position: absolute;
    top: 50%;
    left: 0;
    width: 24px;
    height: 24px;
    margin-top: -12px;
    color: #3d90ff;
    font-size: 12px;
    line-height: 22px;
    text-align: center;
    background-color: #fff;
    border: 1px solid #d9dfe6;
    border-radius: 2px;
    cursor: pointer;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .xwl_main {

  }

  .globalFilters_xwl {
    padding: 0 8px 0 12px;
  }

  .relation-editor {
    position: relative;
    display: flex;
    width: 100%;
  }

  .relation-editor .relation-relation {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 24px;
    margin-right: 4px;
  }

  .relation-relation-line {
    position: absolute;
    top: 0;
    left: 12px;
    width: 1px;
    height: 100%;
    background-color: #d9dfe6;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .relation-editor .relation-relation .relation-relation-value {
    position: absolute;
    top: 50%;
    left: 0;
    width: 24px;
    height: 24px;
    margin-top: -12px;
    color: #3d90ff;
    font-size: 12px;
    line-height: 22px;
    text-align: center;
    background-color: #fff;
    border: 1px solid #d9dfe6;
    border-radius: 2px;
    cursor: pointer;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .relation-editor .relation-main {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0%;
  }

  .relation-editor .relation-relation .relation-relation-sub {
    position: relative;
    top: -7px;
    left: .5px;
    z-index: 100;
    color: #a3acc5;
    font-size: 11px;
  }

  .relation-editor .relation-relation .relation-relation-line-sub {
    position: absolute;
    top: 13px;
    left: 12px;
    width: 1px;
    height: calc(100% - 10px);
    background-color: #d9dfe6;
    transition-property: all;
    transition-duration: 0.3s;
    transition-timing-function: ease;
    transition-delay: 0s;
  }

  .ta-multa-filter-condition {
    padding: 0;
  }

  .relation-row .action-row {
    align-items: center;
    justify-content: flex-start;
  }

  .row___xwl {
    min-height: 32px;
    padding: 2px 4px;
  }

  .action-row .action-left {
    display: flex;
    align-items: center;
  }

  .ta-filter-condition {
    display: inline-block;
    min-height: 32px;
    padding-bottom: 2px;
    white-space: normal;
  }

  .action-row .action-right {
    display: flex;
    align-items: center;
    width: 100px;
  }

  .relation-relation:hover {
    cursor: pointer;
  }

  .relation-relation:hover .relation-relation-line {
    background-color: #3d90ff;
  }

  .relation-relation:hover .relation-relation-value {
    background-color: #3d90ff;
    color: white;
  }

  .relation-relation:hover .relation-relation-line-sub {
    background-color: #3d90ff;
  }

  .relation-relation:hover .relation-relation-sub {
    color: #3d90ff;
  }

  ::-webkit-scrollbar {
    width: 8px; /*对垂直流动条有效*/
    height: 10px; /*对水平流动条有效*/
  }

  /*定义滚动条的轨道颜色、内阴影及圆角*/
  ::-webkit-scrollbar-track {
    border-radius: 3px;
  }

  /*定义滑块颜色、内阴影及圆角*/
  ::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background-color: #e6e6e6;
  }

  /*定义两端按钮的样式*/
  ::-webkit-scrollbar-button {
  }

  /*定义右下角汇合处的样式*/
  ::-webkit-scrollbar-corner {
    background: khaki;
  }
  .eventRow_xwl {
    position: relative;
  }
  .rename_xwl {
    width: auto;
    min-width: 50px;
    max-width: 260px;
    height: 24px;
    margin: 8px 0 0;
    padding: 0;
    line-height: 24px;
    background: inherit;
  }
  .rename_xwl span {
    max-width: 260px;
    font-weight: 500;
    font-size: 13px;
  }
  .rename_xwl input {
    font-weight: 500;
    font-size: 13px;
  }
  .eventRow_xwl .eventItem_xwl {
    max-width: 400px;
    padding: 2px 0 6px;
    overflow: hidden;
    white-space: normal;
  }
  .filters_xwl {
    padding-left: 32px;
  }
  .formula_xwl {
    padding-right: 8px;
    padding-left: 32px;
  }

</style>

<style>
  .zhibiao .ant-input-affix-wrapper .ant-input:focus {
    border: none;
    border-bottom: 1px solid white !important;
    box-shadow: none;
  }
  .zhibiao .ant-input-affix-wrapper .ant-input {
    border: none;
    border-bottom: 1px solid white !important;
    box-shadow: none;
    min-width: 100px !important;
    max-width: 300px !important;
  }
  .gongshi .ant-input-affix-wrapper .ant-input:focus {
    border: none;
    border-bottom: 1px solid white !important;
    box-shadow: none;
  }
  .gongshi .ant-input-affix-wrapper .ant-input {
    border: none;
    border-bottom: 1px solid white !important;
    box-shadow: none;
    min-width: 100px !important;
    max-width: 300px !important;

  }
  .chosen {
    border: solid 2px orange !important;
  }
  .drageTag:hover{
    cursor: pointer;
  }
</style>
